package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30)" json:"username"`
	Password string `gorm:"type:varchar(32)" json:"password"`
}

// 查找
func (u *User) FindUsername() error {
	return DB.Where("username = ?", u.Username).Limit(1).Find(&u).Error
}

// 添加
func (u *User) Create() error {
	return DB.Create(&u).Error
}
